import { AIAPI } from "../type/llmType.js";
import { LLMChatMessage } from "../type/llmType.js";
import { delayS } from "../utils/delay.js";

// 测试用
export class FakeAPI implements AIAPI {
  constructor() {}
  async chat(messages: LLMChatMessage[]): Promise<string> {
    const message: string = messages[messages.length - 1]?.content ?? "";

    if (message.endsWith("error")) {
      throw new Error("模拟错误");
    }
    const processTime = 1 + Math.random();
    await delayS(processTime);
    return `处理时间 ${processTime} `;
  }
}
